import java.util.ArrayList;

/**
 *  从尾到头打印链表
 */
// 递归
public class TestDay2 {
    public static void main(String[] args) {

    }
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        ArrayList<Integer> ret = new ArrayList<>();
        if (listNode == null) return ret;
        print(listNode.next,ret);
        ret.add(listNode.val);
        return ret;
    }
    public void print(ListNode cur,ArrayList<Integer> ret){
        if (cur != null){
            print(cur.next,ret);
            ret.add(cur.val);
        }
    }
}
